package priv.mill.bigdata.autompg;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class AutoMpgDriver {

	public static void main(String[] args) throws Exception {
//		yarn.resourcemanager.hostname
		
		Configuration conf = new Configuration();
//		conf.set("fs.hdfs.impl",org.apache.hadoop.hdfs.DistributedFileSystem.class.getName()); 
//		conf.set("fs.defaultFS", "9000");
//		conf.set("mapreduce.framework.name", "yarn");
//		conf.set("yarn.resourcemanager.hostname", "mini1");
		Job job = Job.getInstance(conf);
		
		job.setJarByClass(AutoMpgDriver.class);
		
		job.setMapperClass(AutoMpgMapper.class);
		job.setReducerClass(AutoMpgReducer.class);
		
		job.setMapOutputKeyClass(IntWritable.class);
		job.setMapOutputValueClass(MyInfo.class);
		
		job.setOutputKeyClass(IntWritable.class);
		job.setOutputValueClass(MyInfo.class);
		
		FileInputFormat.setInputPaths(job, new Path(args[0]));
		FileOutputFormat.setOutputPath(job, new Path(args[1]));
		
		boolean result = job.waitForCompletion(true);
		System.exit(result?0:1);
		
	}

}
